package com.itheima.web.request;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 提交中文乱码情况
 */
@WebServlet("/demo4")
public class RequestDemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //2.解决post字符乱码
        request.setCharacterEncoding("UTF-8");//设置字符输入流编码
        String username = request.getParameter("username");
        System.out.println(username);//乱码
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
